home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: nntp.coast.net!torn!sq!msb
- From: msb@sq.com (Mark Brader)
- Subject: Re: routine for yesterday's date
- Message-ID: <1996Mar31.062512.22480@sq.com>
- Organization: SoftQuad Inc., Toronto, Canada
- References: <315c4d0f.19874776@ottnews.shl.com> <1996Mar30.043002.19054@sq.com> <Dp3B56.FKI@alisa.org>
- Date: Sun, 31 Mar 1996 06:25:12 GMT
-
- > [Why not]
- > long ticks; struct tm * dt;
- > time(&ticks);
- > ticks -= 86400; /* 86400 seconds in a day */
- > dt = localtime (&ticks);
-
- First, this attempts to compute the date 24 hours ago, which may not be
- yesterday in the case of daylight saving time transitions. (It may be
- helpful in the future to read the article you're responding to.)
-
- Second, long should be time_t.
-
- Third, the representation of times and dates within a time_t is not
- defined, so the operation of subtracting 86400 does not produce a known
- result. (On UNIX implementations, of course, it does.)
-
- *That's* why not.
- --
- Mark Brader, msb@sq.com | "B-b-but laziness is the only virtue I have *left*!"
- SoftQuad Inc., Toronto | -- Jutta Degener
-
- My text in this article is in the public domain.
-